<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>等级管理</title>
<link rel="stylesheet" type="text/css" href="__PUBLIC__/style.css" />
<script src="__PUBLIC__/js/jquery.js" type="text/javascript"></script>
<script src="__PUBLIC__/artDialog/jquery.artDialog.js?skin=twitter" type="text/javascript"></script>
<script src="__PUBLIC__/artDialog/plugins/iframeTools.js" type="text/javascript"></script>
</head>
<body>
<div id="main">
    <form id="login-form" action="__URL__/gradeedit" method="post">
        <input type="hidden" value="post" name="action" />
        <input type="hidden" value="{$info['id']}" name="fid" />
        <table width="100%" class="table_form">
            <tr><th width="90">等级名称:</th><td><input id="name" type="text" name="name" class="input-text" size="20" value="{$info['name']}" /></td></tr>
            <tr><th>积分上限:</th><td><input id="vip" type="text" name="vip" class="input-text" size="20" value="{$info['vip']}" /> 仅数字,10:1</td></tr>
            <tr><th>折扣率:</th><td><input id="rebate" type="text" name="rebate" class="input-text" size="3" value="{$info['rebate']}" /> 仅数字,小于"<span class="hot">0</span>"的数字。例:9.5折,填0.95，不优惠填：<span class="hot">1</span></td></tr>
            <tr><th>备注</th><td><textarea name="about" style="width: 350px;height:100px">{$info['about']}</textarea></td></tr>
        </table>
    </form>
</div>
<script type="text/javascript">
    $(function () {
        var parent = art.dialog.parent,	// 父页面window对象
        api = art.dialog.open.api,//art.dialog.open扩展方法
        $ = function (id) {return document.getElementById(id)},
        form = $('login-form'),
        name = $('name'),
        rebate = $('rebate'),
        vip  = $('vip')
        if (!api) return;
        api.title('添加/编辑')// 操作对话框
        .button({ // 自定义按钮
            name: '提交',
            callback: function () {
                if (check(name)&&check(vip)&&num(vip)&&num(rebate)) form.submit();
                return false;
            },focus: true
        },{name: '取消'});
        // 表单验证
        var check = function (input) {
            if (input.value === '') {
                inputError(input);
                input.focus();
                return false;
            } else {
                return true;
            };
        };
        // 是否数字
        var num = function (input) {
            var strP=/^[\+\-]?\d*?\.?\d*?$/;
            if(!strP.test(input.value)){
                inputError(input);
                input.focus();
                return false;
            }else {
                return true;
            };
        };
        // 输入错误提示
        var inputError = function (input){
            clearTimeout(inputError.timer);
            var num = 0;
            var fn = function () {
                inputError.timer = setTimeout(function () {
                    input.className = input.className === '' ? 'login-form-error' : '';
                    if (num === 5) {
                        input.className === '';
                    } else {
                        fn(num ++);
                    };
                }, 150);
            };
            fn();
        };
        window.onload = function () {setTimeout(function () {username.focus()}, 240);};
    })();
</script>
</body>
</html>